#ifndef _cesium_refcounted_hpp_
#define _cesium_refcounted_hpp_

#include "cesium/platform.hpp"

namespace Cesium {

/** Base class for reference counted objects. When instantiated, RefCounted
 *  objects have a reference count of 1.
 */
template<typename T>
class RefCounted {
public:
    RefCounted() : refcount(1) {}
    virtual ~RefCounted() {}

    void ref() {
        refcount++;
    }

    void unref() {
        refcount--;
        if (refcount == 0)
            delete this;
    }

private:
    uint32 refcount;
}; // class RefCounted

} // namespace Cesium

#endif //_cesium_refcounted_hpp_
